package com.cqwu.biz.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.cqwu.bean.Sysuser;
import com.cqwu.biz.SysUserService;
import com.cqwu.dao.SysUserDao;
import com.cqwu.util.PageBean;
import com.cqwu.util.PageUtil;

@Service("sysUserService")
public class SysUserServiceImpl implements SysUserService {
	@Autowired
	@Qualifier("sysUserDao")
	private SysUserDao<Sysuser> sysDao;

	@Transactional
	public Sysuser get(Integer id){	
		return sysDao.get(id);
	}
	
	//分页实验 1.0
	@SuppressWarnings("unchecked")
	public PageBean<Sysuser> getPageData(String pageNum,String uri){
		//hql语句
		String hql = "from Sysuser";
		//总记录数
		Long totalRecord = sysDao.getTotalRecord(Sysuser.class);
		//满足条件的记录集合
		List<Sysuser> list = sysDao.getPageData(hql, pageNum==null?1:Integer.parseInt(pageNum),3);
		return PageUtil.getPageData(pageNum, uri, list, totalRecord);
	}
	
}
